package com.hub.realtime.common.enums;

import java.io.Serializable;
import java.util.Arrays;

public enum JobRunState implements Serializable {

    ADDED(0),
    STARTING(1),
    DEPLOYED(2),
    INITIALIZING(3),
    CREATED(4),
    RESTARTING(6),
    RUNNING(7),
    FAILING(8),
    FAILED(9),
    CANCELLING(10),
    CANCELED(11),
    FINISHED(12),
    SUSPENDED(13),
    RECONCILING(14),
    LOST(15),
    MAPPING(16),
    SILENT(19),
    TERMINATED(20);

    int value;

    JobRunState(int value) {
        this.value = value;
    }

    public int get() {
        return this.value;
    }

    public static JobRunState of(Integer state) {
        return Arrays.stream(values()).filter((x) -> x.value == state).findFirst().orElse(null);
    }
}
